<div class="bjui-pageHeader">
<form id="pagerForm" data-toggle="ajaxsearch" action="__URL__" method="post">
	
	<input type="hidden" name="pageSize" value="{$numPerPage}">
    <input type="hidden" name="pageCurrent" value="{$_REQUEST['pageNum']|default=1}">
	 
        <div class="bjui-searchBar">
            <label>关键词：</label><input type="text" value="{$_REQUEST['keys']}" name="keys" class="form-control" size="15" />
			<label>添加时间：</label><input type="text" data-toggle='datepicker' value="{$_REQUEST['time1']}" name="time1" class="form-control" size="15" />-<input type="text" data-toggle='datepicker' value="{$_REQUEST['time2']}" name="time2" class="form-control" size="15" />
             <button type="submit"  class="btn-default" data-icon="search">查询</button>
              <a class="btn btn-orange" href="javascript:;" onclick="$(this).navtab('reloadForm', true);" data-icon="undo">清空查询</a>
			  <span <php>echo display(CONTROLLER_NAME.'/del');</php> style="float:right;" ><a href="__URL__/del/navTabId/{:CONTROLLER_NAME}" class="btn btn-red" data-toggle="doajax" data-confirm-msg="确定要清理吗？" data-icon="remove">清理</a></span> 
			  <span <php>echo display(CONTROLLER_NAME.'/outxls');</php> style="float:right;margin-right:20px;"><a href="__URL__/outxls" class="btn btn-blue" data-toggle="doexport" data-confirm-msg="确定要导出吗？" data-icon="arrow-up">导出</a></span>

        <span <php>echo display(CONTROLLER_NAME.'/xlsin');</php> style="float:right;margin-right:20px;"><a href="__URL__/xlsinin/navTabId/{:CONTROLLER_NAME}" class="btn btn-blue" data-toggle="dialog" data-width="900" data-height="500" data-confirm-msg="确定要导入吗？" data-icon="arrow-up">导入</a></span>

			  <span <php>echo display(CONTROLLER_NAME.'/add');</php> style="float:right;margin-right:20px;"><a href="__URL__/add/navTabId/{:CONTROLLER_NAME}" class="btn btn-green" data-toggle="dialog" data-width="900" data-height="500" data-id="dialog-mask" data-mask="true" data-icon="plus">新增</a></span>
		</div> 
</form>

<!--分享表单-->
<form id="sharefm" style="margin-top:3px;">
  <label for='juid_input' class='control-label x85' style="width:48px;">分享给:</label><input type='text' id='juid' name='juid'  size='20' data-toggle='lookup' data-url='__MODULE__/public/user/navTabId/{:CONTROLLER_NAME}'  value='{$Rs.juid}'  >

  <label for='juname_input' class='control-label x85'>分享给:</label><input type='text' id='juname' name='juname'  size='20' data-toggle='lookup' data-url='__MODULE__/public/user/navTabId/{:CONTROLLER_NAME}'  value='{$Rs.juname}'  >

  <button type="button" class="btn btn-primary" onclick="custShare()">分享</button>
</form>
    
</div>
<div class="bjui-pageContent">
  <form id="custID">
     <table data-toggle="tablefixed" data-width="100%" data-layout-h="0" data-nowrap="true">
        <thead>
            <tr>
              <th width="10" height="30"></th>
              <th data-order-direction='desc' data-order-field='id'>ID</th>
              <th>公司名称</th>
              <th data-order-direction='desc' data-order-field='fenlei'>进展</th>
              <th data-order-direction='desc' data-order-field='xcrq'>下次联系</th>
              <th>联系人</th>
              <th>手机号码</th>
              
              <th>客户来源</th>
              <th data-order-direction='desc' data-order-field='uname'>添加人</th>
              <th data-order-direction='desc' data-order-field='addtime'>添加时间</th>
              <th data-order-direction='desc' data-order-field='updatetime'>更新时间</th>

              <th><button type="button" class="btn btn-link" onclick="selectall()">全选</button></th>
              <th>详细</th>
              <th <php>echo display(CONTROLLER_NAME.'/del');</php> >状态</th>
              <th <php>echo display(CONTROLLER_NAME.'/edit');</php> >编辑</th>
            </tr>
        </thead>

        <tbody>
          <volist id="v" name="list">
          <tr>
            <td></td>
            <td>{$v.id}</td>
            <td>{$v.title|msubstr=###,0,20}</td>
            <td>{$v.fenlei}</td>
            <td>{$v.xcrq|substr=###,0,10}</td>
            <td>{$v.xingming|msubstr=###,0,20}</td>
            <td>{$v.phone|msubstr=###,0,20}</td>
            
            <td>{$v.type|msubstr=###,0,20}</td>
            <td>{$v.uname}</td>
            <td>{$v.addtime|substr=###,0,10}</td>
            <td>{$v.updatetime|substr=###,0,10}</td>
            <td><input type="checkbox" name="slt[]" value="{$v.id}"></td>

            <td><a href="__URL__/view/id/{$v['id']}/navTabId/{:CONTROLLER_NAME}"  data-toggle="dialog" data-width="900" data-height="500" data-id="dialog-mask" data-mask="true" >详细</a></td>

            <td <php>echo display(CONTROLLER_NAME.'/del');</php> ><a href="__URL__/del/id/{$v['id']}/navTabId/{:CONTROLLER_NAME}" data-toggle="doajax" data-confirm-msg="确定要操作吗？"><if condition="$v.status EQ 1 "><img src="__PUBLIC__/images/ok.gif" border="0"/><else/><img src="__PUBLIC__/images/locked.gif" border="0"/></if></a></td>

            <td <php>echo display(CONTROLLER_NAME.'/edit');</php> > 
            <a href="__MODULE__/custcon/add/cid/{$v['id']}/navTabId/{:CONTROLLER_NAME}"  class="btn btn-green btn-sm" data-toggle="dialog" data-width="900" data-height="500" data-id="dialog-mask" data-mask="true">联系人</a>
            <a href="__MODULE__/custgd/add/cid/{$v['id']}/navTabId/{:CONTROLLER_NAME}"   class="btn btn-green btn-sm" data-toggle="dialog" data-width="900" data-height="500" data-id="dialog-mask" data-mask="true">进展</a>
            <a href="__URL__/edit/id/{$v['id']}/navTabId/{:CONTROLLER_NAME}"   class="btn btn-green btn-sm" data-toggle="dialog" data-width="900" data-height="500" data-id="dialog-mask" data-mask="true" >编辑</a>
            </td>
		        </td>
          </tr> 
          </volist>
        </tbody>
    </table>
  </form>
  
    <script type="text/javascript">
      isselected = false;

      function selectall(){
        if(isselected){
          $("input[type='checkbox']").each(function(){
            this.checked = false;
          });
          isselected = false;
        }else{
          $("input[type='checkbox']").each(function(){
            this.checked = true;
          });
          isselected = true;
        }

      }

      // 执行分享
      function custShare(){
        $.ajax({
          url: "__URL__/cust_share/id/999",
          type: 'post',
          dataType: "json",
          data: $("#sharefm").serialize() + "&" + $("#custID").serialize(),
          success: function(res){
            console.log(res);
            alert("分享成功");
          },
          error: function(err){
            console.warn(err);
            if( err.status == 200 ){
              alert("分享成功");
            }else{
              alert("分享失败，请重新提交");
            }
            
          }
        });
      }
    </script>


    <div class="bjui-footBar">
        <div class="pages">
            <span>共 {$totalCount} 条  每页 {$numPerPage} 条</span>
        </div>
	    <div class="pagination-box" data-toggle="pagination" data-total="{$totalCount}" data-page-size="{$numPerPage}" data-page-current="{$currentPage}">
        </div>
    </div>
</div>